#!/bin/sh
#
# @name KTH-ATMOS
#
# @type Free-Flyer
# @class Spacecraft
#
# @output Motor1 back left thruster, +x thrust
# @output Motor2 front left thruster, -x thrust
# @output Motor3 back right thruster, +x thrust
# @output Motor4 front right thruster, -x thrust
# @output Motor5 front left thruster, +y thrust
# @output Motor6 front right thruster, -y thrust
# @output Motor7 back left thruster, +y thrust
# @output Motor8 back right thruster, -y thrust
#
# @maintainer DISCOWER
# @url https://atmos.discower.io
#

. ${R}etc/init.d/rc.sc_defaults

param set-default CA_AIRFRAME 14
param set-default MAV_TYPE 45

param set-default CA_ROTOR_COUNT 8
param set-default CA_R_REV 0

# Auto to be provided by Custom Airframe
param set-default CA_METHOD 0

# Set proper failsafes
param set-default COM_ACT_FAIL_ACT 0
param set-default COM_LOW_BAT_ACT 0
param set-default NAV_DLL_ACT 0
param set-default GF_ACTION 1
param set-default NAV_RCL_ACT 1

# Set Mocap Vision frame
param set EKF2_EV_CTRL 15
param set EKF2_HGT_REF 3

# disable attitude failure detection
param set-default FD_FAIL_P 0
param set-default FD_FAIL_R 0

param set-default CA_ROTOR0_PX -0.12
param set-default CA_ROTOR0_PY -0.12
param set-default CA_ROTOR0_PZ 0.0
param set-default CA_ROTOR0_CT 1.4
param set-default CA_ROTOR0_AX 1.0
param set-default CA_ROTOR0_AY 0.0
param set-default CA_ROTOR0_AZ 0.0

param set-default CA_ROTOR1_PX 0.12
param set-default CA_ROTOR1_PY -0.12
param set-default CA_ROTOR1_PZ 0.0
param set-default CA_ROTOR1_CT 1.4
param set-default CA_ROTOR1_AX -1.0
param set-default CA_ROTOR1_AY 0.0
param set-default CA_ROTOR1_AZ 0.0

param set-default CA_ROTOR2_PX -0.12
param set-default CA_ROTOR2_PY 0.12
param set-default CA_ROTOR2_PZ 0.0
param set-default CA_ROTOR2_CT 1.4
param set-default CA_ROTOR2_AX 1.0
param set-default CA_ROTOR2_AY 0.0
param set-default CA_ROTOR2_AZ 0.0

param set-default CA_ROTOR3_PX 0.12
param set-default CA_ROTOR3_PY 0.12
param set-default CA_ROTOR3_PZ 0.0
param set-default CA_ROTOR3_CT 1.4
param set-default CA_ROTOR3_AX -1.0
param set-default CA_ROTOR3_AY 0.0
param set-default CA_ROTOR3_AZ 0.0

param set-default CA_ROTOR4_PX 0.12
param set-default CA_ROTOR4_PY -0.12
param set-default CA_ROTOR4_PZ 0.0
param set-default CA_ROTOR4_CT 1.4
param set-default CA_ROTOR4_AX 0.0
param set-default CA_ROTOR4_AY 1.0
param set-default CA_ROTOR4_AZ 0.0

param set-default CA_ROTOR5_PX 0.12
param set-default CA_ROTOR5_PY 0.12
param set-default CA_ROTOR5_PZ 0.0
param set-default CA_ROTOR5_CT 1.4
param set-default CA_ROTOR5_AX 0.0
param set-default CA_ROTOR5_AY -1.0
param set-default CA_ROTOR5_AZ 0.0

param set-default CA_ROTOR6_PX -0.12
param set-default CA_ROTOR6_PY -0.12
param set-default CA_ROTOR6_PZ 0.0
param set-default CA_ROTOR6_CT 1.4
param set-default CA_ROTOR6_AX 0.0
param set-default CA_ROTOR6_AY 1.0
param set-default CA_ROTOR6_AZ 0.0

param set-default CA_ROTOR7_PX -0.12
param set-default CA_ROTOR7_PY 0.12
param set-default CA_ROTOR7_PZ 0.0
param set-default CA_ROTOR7_CT 1.4
param set-default CA_ROTOR7_AX 0.0
param set-default CA_ROTOR7_AY -1.0
param set-default CA_ROTOR7_AZ 0.0


param set-default PWM_AUX_TIM0 10
param set-default PWM_AUX_TIM1 10
param set-default PWM_AUX_TIM2 10

param set-default PWM_AUX_FUNC1 101
param set-default PWM_AUX_FUNC2 102
param set-default PWM_AUX_FUNC3 103
param set-default PWM_AUX_FUNC4 104
param set-default PWM_AUX_FUNC5 105
param set-default PWM_AUX_FUNC6 106
param set-default PWM_AUX_FUNC7 107
param set-default PWM_AUX_FUNC8 108

param set-default PWM_AUX_DIS1 0
param set-default PWM_AUX_DIS2 0
param set-default PWM_AUX_DIS3 0
param set-default PWM_AUX_DIS4 0
param set-default PWM_AUX_DIS5 0
param set-default PWM_AUX_DIS6 0
param set-default PWM_AUX_DIS7 0
param set-default PWM_AUX_DIS8 0

param set-default PWM_AUX_MIN1 0
param set-default PWM_AUX_MIN2 0
param set-default PWM_AUX_MIN3 0
param set-default PWM_AUX_MIN4 0
param set-default PWM_AUX_MIN5 0
param set-default PWM_AUX_MIN6 0
param set-default PWM_AUX_MIN7 0
param set-default PWM_AUX_MIN8 0

# BOARD_PWM_FREQ is downscaled by 10, thus PWM value is given in 10s of usec
param set-default PWM_AUX_MAX1 10000
param set-default PWM_AUX_MAX2 10000
param set-default PWM_AUX_MAX3 10000
param set-default PWM_AUX_MAX4 10000
param set-default PWM_AUX_MAX5 10000
param set-default PWM_AUX_MAX6 10000
param set-default PWM_AUX_MAX7 10000
param set-default PWM_AUX_MAX8 10000

# Controller Tunings
param set-default SC_ROLLRATE_P 0.14
param set-default SC_PITCHRATE_P 0.14
param set-default SC_ROLLRATE_I 0.3
param set-default SC_PITCHRATE_I 0.3
param set-default SC_ROLLRATE_D 0.004
param set-default SC_PITCHRATE_D 0.00
